import request from '@/utils/request'

// 查询商品列表列表
export function listGoods(query) {
  return request({
    url: '/tms/goodsStockHistory/list',
    method: 'get',
    params: query
  })
}

// 导入文件列表查询
export function transportIn(url, type) {
  return request({
    url: `/tms/goodsStockHistory/list_select_import_stock?file=${url}&goodsType=${type}`,
    method: 'get'
  })
}

// 修改入库数量
export function updateStock(data) {
  return request({
    url: '/tms/goodsStockHistory/editStock',
    method: 'post',
    data: data
  })
}

// 普通商品出库根据名称获取商品信息
export function getGoodsDetail(id) {
  return request({
    url: `/tms/goods/detail?goodsNo=${id}`,
    method: 'get'
  })
}

// 普通商品出库根据名称获取商品信息
export function getDriverList(id) {
  return request({
    url: `/tms/goodsParent/detail?parentGoodsNo=${id}`,
    method: 'get'
  })
}

// 删除入库数据
export function delGoods(id) {
  return request({
    url: '/tms/goodsStockHistory/in/' + id,
    method: 'delete'
  })
}
// 删除出库数据
export function delGoodsOut(id) {
  return request({
    url: '/tms/goodsStockHistory/out/' + id,
    method: 'delete'
  })
}

// 出库时导入文件列表查询
export function outGoods(url, type) {
  return request({
    url: `/tms/goodsStockHistory/getParseStockOutData?file=${url}&goodsType=${type}`,
    method: 'get'
  })
}

// 入库保存导入的数据
export function saveGoods(data) {
  return request({
    url: '/tms/goodsStockHistory/batch_import_goods_stock',
    method: 'post',
    timeout:30000,
    data: data,
  })
}

// 入库保存导入的数据(扫码)
export function saveSaoma(id) {
  return request({
    url: `/tms/goods/scanCode?goodsNo=${id}`,
    method: 'get',
  })
}

// 导出库存不足数据
export function excelExport(data) {
  return request({
    url: '/tms/goodsStockHistory/excel_batch_import_goods_stock_out_data',
    method: 'post',
    data: data,
    // headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    responseType: 'arraybuffer'
  })
}

// 获取商品库存操作人集合
export function getPeople() {
  return request({
    url: '/tms/goodsStockHistory/createBy_list',
    method: 'get'
  })
}

// 获取商品库存操作人集合
export function getSupplier() {
  return request({
    url: '/tms/supplier/id_and_name/list',
    method: 'get'
  })
}

// 出库保存导入的数据
export function outGoodsIn(data) {
  return request({
    url: '/tms/goodsStockHistory/batch_import_goods_stock_out_data',
    method: 'post',
    timeout:20000,
    data: data
  })
}

// 新增商品列表
export function addGoods(data) {
  return request({
    url: '/tms/goodsStockHistory',
    method: 'post',
    data: data
  })
}

// 查询商品列表详细
export function getGoods(id) {
  return request({
    url: '/tms/goodsStockHistory/' + id,
    method: 'get'
  })
}

export function goodsPrint(data) {
  return request({
    url: '/tms/goodsStockHistory/select_print_stock',
    method: 'post',
    data: data
  })
}
